Can you use hasLinks on External links?

First time DXL user here... I'm trying to count objects with incoming links, however it returns "0", probably because the incoming links are external links. Is there any way to use hasLinks on external links, or will I have to count them another way?
 

Module m = current
int i0, j0, i1, j1, i2, j2, i3, j3
 
Filter f0 = contains (attribute "Object Heading", "confirm", false) || contains (attribute "Object Heading", "verify", false)
Filter f1 = hasLinks(linkFilterOutgoing, "*")
Filter f2 = hasLinks(linkFilterIncoming, "*")
Filter f3 = f1 && f2
 
set (m, f0, i0, j0)
set (m, f1, i1, j1)
set (m, f2, i2, j2)
set (m, f3, i3, j3)
filtering on
 
print "Objects containing \"Confirm\" or \"Verify\" = " i0 "\n"
print "Objects with a requirement (outgoing) link = " i1 "\n"
print "Objects with a verification (incoming) link = " i2 "\n"
print "Objects with both incoming and outgoing links = " i3 "\n"
 
int diff = i2 - i3
print "Objects with a verification (incoming) link, but no requirement (outgoing) link = " diff "\n"
 
filtering off

 


Output:
Objects containing "Confirm" or "Verify" = 2467
Objects with a requirement (outgoing) link = 1836
Objects with a verification (incoming) link = 0
Objects with both incoming and outgoing links = 0
Objects with a verification (incoming) link, but no requirement (outgoing) link = 0

Thanks in advance!
Nick

P.S. While I'm asking, is there a simple way to count leaves?

 


SystemAdmin - Wed Jun 23 09:07:41 EDT 2010

Re: Can you use hasLinks on External links?
llandale - Wed Jun 23 17:11:42 EDT 2010

I can safely say I've NEVER used this sort of filtering to do anything with DXL. The main reason, of course, is that you have to open the module visibly to do it, which takes drastically longer than opening invisible, and takes up resources.

For this chore, I would go through each object in the module finding objects with links, and counting them. This may get you started.

bool ObjectHasDoorsLinks(Object obj)
{    if (null obj) return(false)
    Link   lnk
    LinkRef lr
    for lnk in obj ->"*" do {return(true)}
    for lr  in obj <-"*" do {return(true)}
    return(false)    // none found
}
 
 
int   CountModule(Module mod)
{     if (null mod) return(0)
 
     int  Count = 0
     Object obj
 
     for obj in entire (mod) do
     {  if (isDeleted(obj))  continue  // don't count links on deleted objects
        if (ObjectHasDoorsLinks(obj)) Count++
     }
     return(Count)
}

 

  • Louie

 

Re: Can you use hasLinks on External links?
SystemAdmin - Thu Jun 24 08:25:08 EDT 2010

llandale - Wed Jun 23 17:11:42 EDT 2010

I can safely say I've NEVER used this sort of filtering to do anything with DXL. The main reason, of course, is that you have to open the module visibly to do it, which takes drastically longer than opening invisible, and takes up resources.

For this chore, I would go through each object in the module finding objects with links, and counting them. This may get you started.

bool ObjectHasDoorsLinks(Object obj)
{    if (null obj) return(false)
    Link   lnk
    LinkRef lr
    for lnk in obj ->"*" do {return(true)}
    for lr  in obj <-"*" do {return(true)}
    return(false)    // none found
}
 
 
int   CountModule(Module mod)
{     if (null mod) return(0)
 
     int  Count = 0
     Object obj
 
     for obj in entire (mod) do
     {  if (isDeleted(obj))  continue  // don't count links on deleted objects
        if (ObjectHasDoorsLinks(obj)) Count++
     }
     return(Count)
}

 

  • Louie

 

Thanks for the reply, I'll give that a try.

Basically, once a week my lead looks at these number and updates his metric, and he has the module open anyway.

I'll still leave the question open for a day or two in case anyone has an answer to the original question.

Again, thanks for the help.

Re: Can you use hasLinks on External links?
SystemAdmin - Thu Jun 24 11:42:48 EDT 2010

SystemAdmin - Thu Jun 24 08:25:08 EDT 2010
Thanks for the reply, I'll give that a try.

Basically, once a week my lead looks at these number and updates his metric, and he has the module open anyway.

I'll still leave the question open for a day or two in case anyone has an answer to the original question.

Again, thanks for the help.

Here's what I ended up doing:
 

Module m = current
Object o
ExternalLink ExtLnk
Link outLnk
int numOutLinks=0, numExtLinks=0, outCount=0, extCount=0, both=0
int test1 = 0, test2 = 0
for o in m do
  {
    for outLnk in o -> "*" do
          {
                numOutLinks++
          }
        if (numOutLinks>0)
          {
                outCount++
                test1 = 1
          }
        else test1 = 0
        numOutLinks = 0
 
        for ExtLnk in o <- "*" do
          {
                numExtLinks++
          }
        if (numExtLinks>0) 
          {
                extCount++
                test2 = 1
          }
        else test2 = 0
        numExtLinks = 0
        if (test1==1 && test2==1) both++
  }
 
print "Objects with a requirement (outgoing) link = " outCount "\n"
print "Objects with a verification (incoming) link = " extCount "\n"
print "Objects with both outgoing and incoming links = " both ""

 


Also, to count leaves:

 

 

int leafCount = 0
for o in m do
  {
    if (leaf (o)==true)
                leafCount++
  }

 

Re: Can you use hasLinks on External links?
SystemAdmin - Thu Jun 24 11:44:26 EDT 2010

I'm assuming you can't use hasLinks on External links, but I coded it a different way.

Re: Can you use hasLinks on External links?
rmoskwa - Thu Jun 24 12:30:46 EDT 2010

Sometimes I use the DOORS Tools->Filter->Define...
to derive a filter of what I want to see. I then look at the
Statistics
Total Objects:
Accepted:
Rejected:
filtering statistics that DOORS presents in the dialog box.

I just have to be able to define a filter.

Re: Can you use hasLinks on External links?
deepbright - Mon May 16 07:56:00 EDT 2016

SystemAdmin - Thu Jun 24 11:44:26 EDT 2010
I'm assuming you can't use hasLinks on External links, but I coded it a different way.

can you please elaborate how did you achieve external link filter.

i need to set a filter of external links on a module like the one below which works for the outgoing links within DOORS

Filter f = hasLinks(linkFilterOutgoing, "*")
set(m, f)
filtering on